@extends('backend::common.common_right')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class=" row m-b-sm m-t-sm">
                            <div class="col-md-6">
                                <form method="get" action="{{url('backend/users')}}">
                                <span class="checkbox col-md-2 m-r-xs" style="margin: 0px;padding: 0px">
                                    <select class="form-control catsshow" id="seach">
                                        <option value="name">用户名</option>
                                        <option value="mobile">手机号</option>
                                    </select>
                               </span>
                                    <div class="input-group">
                                        <input type="text" id="seachname" placeholder="搜索内容" name="name"
                                               class="form-control">
                                        <span class="input-group-btn">
                                     <button type="submit" class="btn  btn-primary"> 搜索</button>
                                     </span>
                                    </div>
                                </form>
                                <div  class="btn-group">
                                    <a class="btn btn-primary" href="{{url('backend/users')}}" aria-pressed="false">全部</a>
                                    <a class="btn btn-primary active" href="{{url('backend/users')}}?is_active=1" aria-pressed="true">正常</a>
                                    <a class="btn btn-primary active" href="{{url('backend/users')}}?is_active=0" aria-pressed="true">禁用</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-striped table-bordered table-hover " id="editable">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>用户名</th>
                                <th>手机号</th>
                                <th>用户money</th>
                                <th>交易币</th>
                                <th>是否VIP</th>
                                <th>VIP到期时间</th>
                                <th>状态</th>
                                <th>注册时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($users as $user)
                                <tr class="gradeX">
                                    <td>{{$user->id}}</td>
                                    <td><a href="{{url('/author')}}?id={{$user->id}}" target="__blank" class="text-navy">{{$user->name}}</a></td>
                                    <td>{{$user->mobile}}</td>
                                    <td class="center">{{$user->money}}</td>
                                    <td class="center">{{$user->coins}}</td>
                                    <td class="center">
                                        @if($user->is_vip)
                                            <button class="btn btn-xs btn-primary">VIP</button>
                                        @else
                                            <button class="btn btn-xs btn-danger">否</button>
                                        @endif
                                    </td>
                                    <td class="center">
                                        @if($user->is_vip)
                                            {{$user->vipduetime}}
                                        @else
                                            -
                                        @endif
                                    </td>
                                    <td class="center">
                                        @if($user->is_active)
                                            <button class="btn btn-xs btn-primary">正常</button>
                                        @else
                                            <button class="btn btn-xs btn-danger">禁用</button>
                                        @endif
                                    </td>
                                    <td class="center">{{$user->created_at}}</td>
                                    <td class="center">
                                        @if($user->is_active)
                                        <a href="javascript:;" onclick="del({{$user->id}})"><i class="fa fa-trash"></i>禁用</a>
                                        @else
                                        <a href="javascript:;" onclick="use({{$user->id}})"><i class="fa fa-check-circle-o"></i>启用</a>
                                        @endif
                                        <a href="{{url('backend/userinfo',['id'=>$user->id])}}" ><i class="fa fa-user-secret"></i>详情</a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        {{$users->links()}}
                    </div>
                </div>
            </div>
        </div>
        <script>
            $('#seach').change(function () {
                var seachname = $(this).children('option:selected').val()
                $("#seachname").attr('name', seachname);
            })
            var del = function (id) {
                layer.confirm('禁用此用户？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    window.location.href = "{{url('backend/usersdel')}}/" + id;
                }, function () {
                });
            }

            var use = function (id) {
                layer.confirm('启用此用户？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    window.location.href = "{{url('backend/usersuse')}}/" + id;
                }, function () {
                });
            }
        </script>

@endsection

